/**
 * Created by JetBrains WebStorm.
 * User: denysk
 * Date: 6/10/11
 * Time: 8:31 AM
 * To change this template use File | Settings | File Templates.
 */
Namespace("sketch.ui");

(function($,fwk,ui){
	ui.Toolbar = function(toolbarId){
        var undoElement = $(toolbarId + " .undo:first")
            .hide()
            .click(function(){
                    fwk.commandManager.undoPrevious();
                });

        var redoElement = $(toolbarId + " .redo:first")
            .hide()
            .click(function(){
                    fwk.commandManager.redoNext();
                });

        fwk.commandManager.properties.bind("canUndo", function(event){
            if (event.newValue){
                undoElement.show();
            }
            else{
                undoElement.hide();
            }
        });

        fwk.commandManager.properties.bind("canRedo", function(event){
            if (event.newValue){
                redoElement.show();
            }
            else{
                redoElement.hide();
            }
        });
	};

})(jQuery, sketch.framework, sketch.ui);
